package com.allwees.core.common.util.encrypt;

import org.apache.commons.codec.binary.Hex;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util {
	public static String digest(String origin) {
		try {
			MessageDigest digest = MessageDigest.getInstance("MD5");
			byte[] bytes = digest.digest(origin.getBytes());
			return new String(Hex.encodeHex(bytes));
		} catch (NoSuchAlgorithmException e) {
			throw new RuntimeException(e);
		}
	}

	public static String md516(String encode) {
		return digest(encode).substring(8, 24);
	}
}
